﻿using System;
using System.Text;

namespace SimplePoll.Web.DataAccess
{
    public static class KeyExtensions
    {
        public static string Decode(this string key)
        {
            if (key == null)
                return null;

            return Encoding.UTF8.GetString(Convert.FromBase64String(key));
        }

        public static string Encode(this string key)
        {
            if (key == null)
                return null;

            return Convert.ToBase64String(Encoding.UTF8.GetBytes(key));
        }
    }
}